Skip to content

Move telemetry auth helpers from cmd/aitools to cmd/root - #8158

Open
simonfaltum wants to merge 2 commits into
skills/t1-telemetry-for-the-skills-commandsfrom
skills/t1root-move-the-telemetry-auth-helpers-from-cmd
Open

simonfaltum wants to merge 2 commits into
skills/t1-telemetry-for-the-skills-commandsfrom
skills/t1root-move-the-telemetry-auth-helpers-from-cmd

Conversation

@simonfaltum

@simonfaltum simonfaltum commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Changes

cmd/skills imports cmd/aitools only for the telemetry auth helpers and the calling-agent mapping. This PR moves those into cmd/root and points cmd/skills there, so the skills commands no longer import cmd/aitools. It is stacked on #8145 (base skills/t1-telemetry-for-the-skills-commands) and has no behaviour change.

  • WithTelemetryAuth, TelemetryAuth, their helpers and the wait budget move from cmd/aitools/telemetry.go to cmd/root/telemetry_auth.go.
  • AgentType (the agent registry to telemetry enum mapping) and CallingAgentType move to cmd/root/root.go.
  • cmd/skills imports cmd/root instead of cmd/aitools.
  • The aitools call sites use root.AgentType, root.CallingAgentType, root.WithTelemetryAuth and root.TelemetryAuthBudget.

Why

The lint config lets cmd/aitools import only cmd/root and itself, so code that both command groups share belongs in cmd/root. The move is a separate pull request so that reviewers can check it without the behaviour changes in #8145.

Decisions to review

  • TelemetryAuthBudget and TelemetryAuthResolver are exported package variables. The aitools tests in another package stub them to keep install and update tests off the host's auth. The alternative was a test-only export file, which the other package cannot import.
  • AgentType and CallingAgentType go in root.go, the only cmd/root file that may import libs/aitools, under the root-aitools-hooks-in-root-go lint rule.
  • Two tests that call the unexported pending-resolution type move to cmd/root/telemetry_auth_test.go. The rest of the aitools telemetry auth tests stay where they are.
  • TestAgentTypeCoversRegistry moves to cmd/root/root_test.go, next to AgentType that it guards.

Tests

  • go test ./cmd/root/... ./cmd/aitools/... ./cmd/skills/... passes. TestTelemetryAuthFinishedResolutionSurvivesAnExpiredBudget covers the moved wait behaviour.
  • go test ./acceptance -run 'TestAccept/cmd/aitools' and -run 'TestAccept/cmd/skills' pass with no golden changes.
  • ./task --force fmt-q lint-q, ./task aitools-quick and the deadcode check pass.

This pull request and its description were written by Isaac.

WithTelemetryAuth, TelemetryAuth and their helpers move into cmd/root,
together with the agent type mapping and CallingAgentType, so cmd/skills
no longer imports cmd/aitools. This is a pure move with no behaviour
change: the aitools and skills acceptance tests are unchanged.

Co-authored-by: Isaac <no-reply@databricks.com>
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Regression test report ✅

Commit: 3f8d9fcde | Workflow run

Selected 1 changed tests (limit=20, 0 not selected)

1 tests: regression=1 unreleased=0 coverage=0 failing=0
test branch main (e6f3460) latest (v1.28.0)
TestAccept/cmd/skills/telemetry ✅ ❌ ❌
TestAccept/cmd/skills/telemetry: branch ✅ | main (e6f3460) ❌ | latest (v1.28.0) ❌

main (e6f3460):

acceptance_test.go:1402: Diff:
        --- cmd/skills/telemetry/output.txt
        +++ /tmp/TestAcceptcmdskillstelemetry1637171394/002/output.txt
        @@ -5,14 +5,12 @@
         Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install
         
         >>> print_skills
        -{"calling_agent":"CLAUDE_CODE","command":"LIST","catalog_release_version":"0.0.1","source":"FOLDER","outcome":"SUCCEEDED"}
         
         === skills read from a folder: the name is not sent, the release version and the source are
         
         >>> [CLI] skills read guide-skill
         
         >>> print_skills
        -{"calling_agent":null,"command":"READ","catalog_release_version":"0.0.1","source":"FOLDER","outcome":"SUCCEEDED"}
         
         === a failed read sends the error category and the version
         
        @@ -20,7 +12,6 @@
         Error: unknown skill "no-such-skill": run "databricks skills list" to see the available skills
         
         >>> print_skills
        -{"calling_agent":null,"command":"READ","catalog_release_version":"0.0.1","source":"FOLDER","outcome":"FAILED","error_category":"SKILL_NOT_FOUND"}
         
         === with telemetry disabled, nothing is uploaded
         
        
    acceptance_test.go:1180: 
        LOG.disabled: ---
        LOG.disabled: name: guide-skill
        LOG.disabled: description: A skill with a supporting file.
        LOG.disabled: ---
        LOG.disabled: 
        LOG.disabled: # Guide skill
        LOG.disabled: 
        LOG.disabled: Read the guide in references for details.
        LOG.disabled: 
        LOG.disabled: Other files in this skill, each read with its command:
        LOG.disabled:   databricks skills read-file guide-skill references/guide.md
        LOG.disabled:   databricks skills read-file -- guide-skill -notes.md
    acceptance_test.go:1180: 
        LOG.list: Pick the skill whose description matches the task.
        LOG.list: Read the skill before you act on it.
        LOG.list: 
        LOG.list: demo-skill: A skill for tests.
        LOG.list: future-skill: A skill that needs a newer CLI.
        LOG.list: guide-skill: A skill with a supporting file.
        LOG.list: To read a skill, run: databricks skills read <name>
    acceptance_test.go:1180: 
        LOG.off: Pick the skill whose description matches the task.
        LOG.off: Read the skill before you act on it.
        LOG.off: 
        LOG.off: demo-skill: A skill for tests.
        LOG.off: future-skill: A skill that needs a newer CLI.
        LOG.off: guide-skill: A skill with a supporting file.
        LOG.off: To read a skill, run: databricks skills read <name>
    acceptance_test.go:1180: 
        LOG.on: Pick the skill whose description matches the task.
        LOG.on: Read the skill before you act on it.
        LOG.on: 
        LOG.on: demo-skill: A skill for tests.
        LOG.on: future-skill: A skill that needs a newer CLI.
        LOG.on: guide-skill: A skill with a supporting file.
        LOG.on: To read a skill, run: databricks skills read <name>
    acceptance_test.go:1180: 
        LOG.read: ---
        LOG.read: name: guide-skill
        LOG.read: description: A skill with a supporting file.
        LOG.read: ---
        LOG.read: 
        LOG.read: # Guide skill
        LOG.read: 
        LOG.read: Read the guide in references for details.
        LOG.read: 
        LOG.read: Other files in this skill, each read with its command:
        LOG.read:   databricks skills read-file guide-skill references/guide.md
        LOG.read:   databricks skills read-file -- guide-skill -notes.md
FAIL

latest (v1.28.0):

acceptance_test.go:1402: Diff:
        --- cmd/skills/telemetry/output.txt
        +++ /tmp/TestAcceptcmdskillstelemetry1386995481/002/output.txt
        @@ -2,30 +2,6 @@
         === skills list under a coding agent: the event and the calling agent are uploaded
         
         >>> [CLI] skills list
        -Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install
        +Error: unknown command "skills" for "databricks"
         
        ->>> print_skills
        -{"calling_agent":"CLAUDE_CODE","command":"LIST","catalog_release_version":"0.0.1","source":"FOLDER","outcome":"SUCCEEDED"}
        -
        -=== skills read from a folder: the name is not sent, the release version and the source are
        -
        ->>> [CLI] skills read guide-skill
        -
        ->>> print_skills
        -{"calling_agent":null,"command":"READ","catalog_release_version":"0.0.1","source":"FOLDER","outcome":"SUCCEEDED"}
        -
        -=== a failed read sends the error category and the version
        -
        ->>> [CLI] skills read no-such-skill
        -Error: unknown skill "no-such-skill": run "databricks skills list" to see the available skills
        -
        ->>> print_skills
        -{"calling_agent":null,"command":"READ","catalog_release_version":"0.0.1","source":"FOLDER","outcome":"FAILED","error_category":"SKILL_NOT_FOUND"}
        -
        -=== with telemetry disabled, nothing is uploaded
        -
        ->>> [CLI] skills read guide-skill
        -
        ->>> print_skills
        -
        -=== output is the same with telemetry on and off
        +Exit code: 1
        
    acceptance_test.go:1180: LOG.list: 
FAIL

@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: 3f8d9fc

Run: 46104069460

Env 💚​RECOVERED ✅​pass 🙈​skip Time
💚​ aws linux-2core-8gb 1 173 18 3:34
💚​ aws-windows-latest-4core-16gb 1 173 18 3:24
💚​ azure linux-2core-8gb 1 172 18 3:31
💚​ azure-windows-latest-4core-16gb 1 172 18 3:24
💚​ gcp linux-2core-8gb 1 173 18 4:07
💚​ gcp-windows-latest-4core-16gb 1 173 18 3:13
Test Name aws linux-2core-8gb aws-windows-latest-4core-16gb azure linux-2core-8gb azure-windows-latest-4core-16gb gcp linux-2core-8gb gcp-windows-latest-4core-16gb
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
Top 6 slowest tests (at least 2 minutes):
duration env testname
3:31 gcp linux-2core-8gb TestAccept
3:28 azure linux-2core-8gb TestAccept
3:22 azure-windows-latest-4core-16gb TestAccept
3:22 aws-windows-latest-4core-16gb TestAccept
3:18 aws linux-2core-8gb TestAccept
3:11 gcp-windows-latest-4core-16gb TestAccept

@simonfaltum
simonfaltum marked this pull request as ready for review November 28, 2026 03:03
@simonfaltum
simonfaltum requested review from a team and lennartkats-db as code owners November 28, 2026 03:03

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review at df722a4. Each finding was verified against the code.

No blocking issues found. 2 non-blocking comment(s) and 1 question(s) below.

This PR moves the telemetry auth helpers (WithTelemetryAuth, TelemetryAuth, the budget and resolver) from cmd/aitools to cmd/root/telemetry_auth.go, and AgentType/CallingAgentType to cmd/root/root.go, so cmd/skills no longer imports cmd/aitools. The moved production code matches the base version, apart from the renames, and every call site points to the new locations. What's left is cleanup: the two moved tests were rewritten into one instead of being moved as they were, and the registry coverage test for AgentType still sits in cmd/aitools and refers to the old function name.

Questions

  1. AgentType and CallingAgentType only map libs/aitools/agents names to protos values, and nothing in cmd/root calls them. The root-aitools-hooks-in-root-go lint rule exists for the root pre/post-run hooks, and the depguard message says shared aitools code should go through libs/aitools. Should these two functions live in libs/aitools (for example libs/aitools/agents) instead? Or, if they stay in root.go, should that lint rule's comment mention this use? (non-blocking)

Comment thread cmd/root/telemetry_auth_test.go Outdated
// A resolution that has already finished still counts, with or without the
// wait, even once the budget has passed. The repeats make a race between
// "done" and "not done" fail reliably.
func TestTelemetryAuthFinishedResolutionSurvivesAnExpiredBudget(t *testing.T) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nice to have] TestTelemetryAuthFinishedResolutionSurvivesAnExpiredBudget and TestTelemetryAuthNoWaitUsesFinishedResolution from cmd/aitools/telemetry_auth_test.go are now one table-driven test. The second name is gone, and the authTestCmd fixture (--profile flag, WithTelemetryAuth with WaitAtExit) is replaced by a bare cobra.Command and inline setup. That means this "no behaviour change" move can't be checked as a straight copy. AGENTS.md asks that moved code not be changed along the way. Can we move both tests unchanged, with a small local helper, and do the table-driven merge separately?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 3f8d9fc. Both tests are back in cmd/root unchanged, from the parent branch, with their shared setup in two small local helpers (setTelemetryAuth and authTestCmd). The table-driven merge is not in this pull request. It can follow as its own change.

Comment thread cmd/aitools/telemetry_test.go Outdated
for _, a := range agents.Registry {
assert.NotEqualf(t, protos.AitoolsAgentTypeUnspecified, agentType(a.Name),
assert.NotEqualf(t, protos.AitoolsAgentTypeUnspecified, root.AgentType(a.Name),
"agent %q has no telemetry enum: add a case to agentType and a value to "+

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nice to have] AgentType now lives in cmd/root/root.go, but TestAgentTypeCoversRegistry stays in cmd/aitools. Someone who adds a case and runs go test ./cmd/root/... never runs the guard, even though the doc comment on root.AgentType names it as if it sat next to the function. The failure message here and the test's comment on line 73 also still say agentType. Can we move the test to cmd/root, which already imports libs/aitools/agents in root.go, and update the name to AgentType?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 3f8d9fc. TestAgentTypeCoversRegistry moved to cmd/root/root_test.go, next to root.AgentType. The failure message and the doc comment now name root.AgentType.

Move the two cmd/aitools auth tests into cmd/root unchanged, with small
local helpers, instead of merging them into one table-driven test. Move
TestAgentTypeCoversRegistry to cmd/root next to root.AgentType and name
root.AgentType in its failure message and comment.

Co-authored-by: Isaac <no-reply@databricks.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants